<{capture name="header"}>
<{css app="ome" src="ome.css"}>
<{css app="ome" src="style.css"}>
<{script src="coms/modedialog.js" app="desktop"}>
<{script src="coms/pager.js" app="desktop"}>
<{/capture}>
<style>
    .notice-inline.error  {background-image:none;margin-left:25px}
    #fm1 .division td label ,#fm1 .division div label {vertical-align:top;}
</style>
<form method="post" id="fm1" action="index.php?app=material&ctl=admin_material_replace&act=toAdd">
    <div class="tableform">
        <h3>物料替换信息</h3>
        <div class="division">
            <h5>基本信息</h5>
            <table border="0" cellspacing="0" cellpadding="0" class="gridlist">
                <thead>
                <tr>
                    <td width="10%" align="right" nowrap="nowrap">
                        原物料：
                    </td>
                    <td>
                        <input type="text" name="material_bn" vtype="required"/>
                        <span style="color:red;">*</span>
                    </td>
                </tr>
                <tr>
                    <td width="10%" align="right" nowrap="nowrap">
                        原料品数量：
                    </td>
                    <td>
                        <input type="text" name="num" vtype="required" onkeyup="value=value.replace(/[^0-9]/ig,'')"/>
                        <span style="color:red;">*</span>
                    </td>
                <tr>
                    <td width="10%" align="right" nowrap="nowrap">
                        替代物料：
                    </td>
                    <td>
                        <input type="text" name="rep_material_bn" vtype="required" onkeyup="value=value.replace(/[^A-Za-z0-9_-]/ig,'')"/>
                        <span style="color:red;">*</span>
                    </td>
                </tr>
                <tr>
                    <td width="10%" align="right" nowrap="nowrap">
                        替代数量：
                    </td>
                    <td>
                        <input type="text" name="replaceNum" vtype="required" value="1" readonly="
                        true" />
                        <span style="color:red;">*</span>
                    </td>
                </tr>
                <tr>
                    <td width="10%" align="right">所属店铺：</td>
                    <td>    <div class="gridlist clearfix">
                          <div class="row" id="shops">
                            <div class="row-line shops-list" style="padding:5px;">
                              <div class="span-2"><strong>所属店铺</strong></div>
                              <div class="span-13">
                                <{foreach from=$shops item=item}>
                                <div class="span-auto">
                                  <label><input class="shopIds" type="checkbox" value="<{$item.shop_id}>" name="shopIds[]" <{if in_array($item.shop_id, $shopIds) }>checked='checked'<{/if}> /><{$item.name}></label>
                                </div>
                                <{/foreach}>
                              </div>
                            </div>
                          </div>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td width="10%" align="right" nowrap="nowrap">
                        开始时间：
                    </td>
                    <td>
                        <{input type="time" name="start_time" vtype="required" id="start_time" value="{$start_time}" }>
                        <span style="color:red;">*</span>
                    </td>
                </tr>
                <tr>
                    <td width="10%" align="right" nowrap="nowrap">
                        结束时间：
                    </td>
                    <td>
                        <{input type="time" name="end_time" vtype="required" id="end_time" value="{$end_time}" }>
                        <span style="color:red;">*</span>
                    </td>
                </tr>
                <tr>
                    <td width="10%" align="right" nowrap="nowrap">
                        权重：
                    </td>
                    <td>
                        <input type="text" name="priority" vtype="required" onkeyup="value=value.replace(/[^0-9]/ig,'')"/>
                        <span style="color:red;">*</span>
                    </td>
                </tr>
                <tr>
                    <td width="10%" align="right" nowrap="nowrap">
                        是否开启：
                    </td>
                  <td>
                       <input type="radio" name="disabled" value='true' checked="checked" />是
                       <input type="radio" name="disabled" value='false' />否
                  </td>
                </tr>
                <tr>
                    <td width="10%" align="right" nowrap="nowrap">
                        备注：
                    </td>
                    <td>
                        <textarea name="desc" id="" cols="50" rows="5"></textarea>
                    </td>
                </tr>
                </thead>
            </table>

        <div id="cc" class="noprint table-action">
            <{button type="button" id="material-save-btn" label="保 存"}> &nbsp;
            <{button type="button" class="btn-secondary" id="return-btn" label="关 闭" onclick="javascript:void(window.close());"}>
        </div>
    </div>
</form>
<script>
(function() {
    window.addEvent('domready', function() {

        var pag,rows;
        $('material-save-btn').addEvent('click',function(e){
            var _this=this;
            var form=this.getParent('form');
            if(pag){
                var data=pag.toHideInput($('dataNode').getElement('tr'));
                form.store('target',{extraData:data,
                    onRequest:function(){
                        _this.disabled=true;
                    },
                    onComplete:function(jsontext){
                        try{
                            var json = JSON.decode(jsontext);
                            if (typeof(json.error)!='undefined'){
                                _this.disabled=false;
                            }else{
                                _this.disabled=true;
                                if(opener.finderGroup['<{$env.get.finder_id}>']) opener.finderGroup['<{$env.get.finder_id}>'].refresh.delay(100,opener.finderGroup['<{$env.get.finder_id}>']);
                                setTimeout('window.close()',200);
                            }
                        }catch(e){}
                    }
                });
            }else{
                form.store('target',{
                    onRequest:function(){
                        _this.disabled=true;
                    },
                    onComplete:function(jsontext){
                        try{
                            var json = JSON.decode(jsontext);
                            if (typeof(json.error)!='undefined'){
                                _this.disabled=false;
                            }else{
                                _this.disabled=true;
                                if(opener.finderGroup['<{$env.get.finder_id}>']) opener.finderGroup['<{$env.get.finder_id}>'].refresh.delay(100,opener.finderGroup['<{$env.get.finder_id}>']);
                                setTimeout('window.close()',300);
                            }
                        }catch(e){}
                    }
                });
            }
            form.fireEvent('submit',e);
        });
    });
})();

</script>